package nl.mikoosoft.sport.stoer.domain;

import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import javax.validation.constraints.Size;
import nl.mikoosoft.sport.stoer.domain.Tournament;
import javax.persistence.ManyToOne;
import java.util.Set;
import nl.mikoosoft.sport.stoer.domain.Team;
import java.util.HashSet;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;

@RooJavaBean
@RooToString
@RooEntity(identifierColumn = "division_id")
public class Division {

    @Size(max = 32)
    private String name;

    @Size(min = 1, max = 10)
    private String designator;

    @Size(max = 15)
    private String className;

    @ManyToOne
    private Tournament tournament;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "division")
    private Set<Team> teams = new HashSet<Team>();
}
